#ifndef _DEFINITIONS_
#define _DEFINITIONS_


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <net/ethernet.h>
#include <netinet/ether.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <arpa/inet.h>
#include <map>
#include <list>
#include <string>


using namespace std;



struct sniff_ethernet {
        u_char  ether_dhost[6];    /* destination host address */
        u_char  ether_shost[6];    /* source host address */
        u_short ether_type;                     /* IP? ARP? RARP? etc */
};

/* IP header */
struct sniff_ip {
        u_char  ip_vhl;                 /* version << 4 | header length >> 2 */
        u_char  ip_tos;                 /* type of service */
        u_short ip_len;                 /* total length */
        u_short ip_id;                  /* identification */
        u_short ip_off;                 /* fragment offset field */
        #define IP_RF 0x8000            /* reserved fragment flag */
        #define IP_DF 0x4000            /* dont fragment flag */
        #define IP_MF 0x2000            /* more fragments flag */
        #define IP_OFFMASK 0x1fff       /* mask for fragmenting bits */
        u_char  ip_ttl;                 /* time to live */
        u_char  ip_p;                   /* protocol */
        u_short ip_sum;                 /* checksum */
        struct  in_addr ip_src,ip_dst;  /* source and dest address */
};
#define IP_HL(ip)               (((ip)->ip_vhl) & 0x0f)
#define IP_V(ip)                (((ip)->ip_vhl) >> 4)



unsigned short in_cksum(unsigned short *addr, int len);


u_char * nametoaddr(const char * devname);

void
got_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *packet);

void
got_packet2(u_char *args, const struct pcap_pkthdr *header, const u_char *packet);


void* sniffer1_thread_func(void*);

void* sniffer2_thread_func(void*);

void* rdwrif1_thread_func(void*);

void* rdwrif2_thread_func(void*);

void* icmp_thread_func(void*);


extern list<string> interface_list;		

extern map<string,string> ipadd_map;

extern list<unsigned char*> packet_q_i1;

extern list<unsigned char*> packet_q_i2;


#endif